import AJAX from '@/common/ajax'

export const GET_SLIDE = 'GET_SLIDE'

export default {
  namespaced: true,
  state: {
    slide: ''
  },
  mutations: {
    [GET_SLIDE](state, data) {
      state.slide = data
      console.log('state.slide', state.slide)
    }
  },
  actions: {
    async getSlide({ commit, state }) {
      const data = state.slide
      if (data) {
        return data
      } else {
        let [err, data] = await AJAX({
          name: 'slide'
        })
        commit(GET_SLIDE, data)
        return data
      }
    }
  }
}
